home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / fgl110c.zip / 10-05.C < prev    next >
Text File  |  1992-01-31  |  1KB  |  59 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. #define VISUAL 0
  8. #define HIDDEN 1
  9.  
  10. void main()
  11. {
  12.    int new_mode, old_mode;
  13.    int frame, offset;
  14.    int i;
  15.  
  16.    /* initialize the video environment */
  17.  
  18.    new_mode = fg_bestmode(320,200,2);
  19.    if (new_mode < 0 || new_mode == 12) {
  20.       printf("This program requires a 320 ");
  21.       printf("x 200 color graphics mode.\n");
  22.       exit(1);
  23.       }
  24.    old_mode = fg_getmode();
  25.    fg_setmode(new_mode);
  26.    fg_allocate(HIDDEN);
  27.  
  28.    /* draw the background in the upper left corner */
  29.  
  30.    fg_setpage(HIDDEN);
  31.    fg_setcolor(1);
  32.    fg_rect(0,95,0,49);
  33.    fg_setcolor(15);
  34.    fg_move(48,25);
  35.    fg_ellipse(20,20);
  36.  
  37.    /* copy it to the center of the visual page */
  38.  
  39.    fg_transfer(0,95,0,49,112,124,HIDDEN,VISUAL);
  40.  
  41.    /* slide the object across the background three times */
  42.  
  43.    fg_setcolor(10);
  44.    for (i = 0; i < 36; i++) {
  45.       frame  = i % 12;
  46.       offset = 10 * frame - 10;
  47.       fg_transfer(0,95,20,29,112,105,HIDDEN,HIDDEN);
  48.       fg_rect(112+offset,131+offset,96,105);
  49.       fg_transfer(112,207,96,105,112,105,HIDDEN,VISUAL);
  50.       fg_waitfor(2);
  51.       }
  52.  
  53.    /* restore the original video mode and return to DOS */
  54.  
  55.    fg_freepage(HIDDEN);
  56.    fg_setmode(old_mode);
  57.    fg_reset();
  58. }
  59.